home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_weap_carbgun_m.cog < prev    next >
Text File  |  1998-02-25  |  19KB  |  623 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # WEAP_CARBGUN_M.COG
  4. #
  5. # WEAPON 20 Script - Carbonite Gun
  6. #
  7. # [YB & CYW] + [RF]
  8. #
  9. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  10.  
  11.  
  12. symbols
  13.  
  14. model       povModel=cbnv_m.3do                 local
  15. model       povModel_m=cbnv.3do                 local
  16. model       weaponMesh=cbng.3do                 local
  17.  
  18. keyframe    thirdWhack=KKcarbf2.key             local
  19. keyframe    povWhack=CbnVpst2.key               local
  20.  
  21. keyframe    mountAnim=BowVmnt.key               local
  22. keyframe    dismountAnim=BowVdis.key            local
  23. keyframe    povfireAnim=BowVpst1.key            local
  24. keyframe    holsterAnim=kyhlstr.key             local
  25.  
  26. #keyframe    mountAnim=bryvmnt.key              local
  27. #keyframe    dismountAnim=bryvdis.key           local
  28. #keyframe    povfireAnim=bryvpst1.key           local
  29. #keyframe    holsterAnim=kyhlstr.key            local
  30.  
  31. sound       fistSound=SwingFist01.wav           local
  32. template    projPunch=+bigpunch                 local
  33.  
  34. sound       outSound=pistout1.wav               local
  35. sound       mountSound=df_bry_ready.wav         local
  36. sound       dismountSound=PutWeaponAway01.wav   local
  37. sound       fireSound=cgunfire.wav              local
  38. sound       failSound=weapfail.wav              local
  39. #sound       powering=00industrialamb01.wav      local
  40.  
  41. template    projectile=+bryarbolt               local
  42. template    cprojectile=+carbsparks             local
  43.  
  44. template    carboExplode=+sparks                local
  45.  
  46. template    csTpl=+CarboniteStem                local
  47. template    c0Tpl=+CarboDebris_0                local
  48. template    c1Tpl=+CarboDebris_1                local
  49. template    c2Tpl=+CarboDebris_2                local
  50. template    c3Tpl=+CarboDebris_3                local
  51. template    c4Tpl=+CarboDebris_4                local
  52.  
  53. int         debris                              local
  54.  
  55. thing       player                              local
  56. thing       victim                              local
  57. thing       potential                           local
  58.  
  59. flex        damageType                          local
  60. flex        damage                              local
  61.  
  62. flex        dot                                 local
  63. flex        maxDot                              local
  64. flex        soundPitch                          local
  65.  
  66. flex        fireWait=0.5                        local
  67. flex        holsterWait                         local
  68. flex        fireDelay=0.6                       local
  69. flex        powerBoost                          local
  70. flex        autoAimFOV=30                       local
  71. flex        autoAimMaxDist=5                    local
  72. int         fireSize                            local
  73.  
  74. int         weaponIndex                         local
  75. int         trackID=-1                          local
  76. int         dummy=0                             local
  77. int         mode                                local
  78. int         holsterTrack                        local
  79. int         smackTrack                          local
  80. int         powerChannel                        local
  81. int         i                                   local
  82. int         j                                   local
  83. int         k                                   local
  84.  
  85. vector      randVec                             local
  86.  
  87. thing       statueList=-1                       local
  88. thing       statueList2=-1                      local
  89. thing       statueList3=-1                      local
  90. thing       statueList4=-1                      local
  91. thing       statueList5=-1                      local
  92. thing       statueList6=-1                      local
  93. thing       statueList7=-1                      local
  94. thing       statueList8=-1                      local
  95. thing       statueList9=-1                      local
  96. thing       statueList10=-1                     local
  97. thing       statueList11=-1                     local
  98. thing       statueList12=-1                     local
  99. thing       statueList13=-1                     local
  100. thing       statueList14=-1                     local
  101. thing       statueList15=-1                     local
  102. thing       statueList16=-1                     local
  103. thing       statueList17=-1                     local
  104. thing       statueList18=-1                     local
  105. thing       statueList19=-1                     local
  106. thing       statueList20=-1                     local
  107.  
  108. thing       hitList=-1                          local
  109. thing       hitList2=-1                         local
  110. thing       hitList3=-1                         local
  111. thing       hitList4=-1                         local
  112. thing       hitList5=-1                         local
  113. thing       hitList6=-1                         local
  114. thing       hitList7=-1                         local
  115. thing       hitList8=-1                         local
  116. thing       hitList9=-1                         local
  117. thing       hitList10=-1                        local
  118.  
  119. int         lastHit=-1                          local
  120. int         lastHit2=-1                         local
  121. int         lastHit3=-1                         local
  122. int         lastHit4=-1                         local
  123. int         lastHit5=-1                         local
  124. int         lastHit6=-1                         local
  125. int         lastHit7=-1                         local
  126. int         lastHit8=-1                         local
  127. int         lastHit9=-1                         local
  128. int         lastHit10=-1                        local
  129.  
  130. int         hitCount=0                          local
  131. int         hitCount2=0                         local
  132. int         hitCount3=0                         local
  133. int         hitCount4=0                         local
  134. int         hitCount5=0                         local
  135. int         hitCount6=0                         local
  136. int         hitCount7=0                         local
  137. int         hitCount8=0                         local
  138. int         hitCount9=0                         local
  139. int         hitCount10=0                        local
  140.  
  141. int         hitSide                             local
  142.  
  143. thing       aiCarbonited                        local
  144. template    carboDummy=+CarboniteChar           local
  145.  
  146. flex        freezeradius=1.5                    local
  147. thing       frozen                              local
  148.  
  149.  
  150. message     activated
  151. message     deactivated
  152. message     selected
  153. message     deselected
  154. message     autoselect
  155. message     fire
  156. message     timer
  157.  
  158. message     damaged
  159. message     user0
  160.  
  161. end
  162.  
  163. # ========================================================================================
  164.  
  165. code
  166.  
  167. fire:
  168.     SendMessageEx(GetThingClassCog(GetLocalPlayerThing()), user1, 3, 0, 0, 0);
  169.  
  170.     if (mode == 0)
  171.     {
  172.         fireSize = 0.2;
  173.         call vire;
  174.     }
  175.     else
  176.     {
  177.         call mire;
  178.     }
  179.    return;
  180.  
  181. # ........................................................................................
  182.  
  183. vire:        // Fire carbonite
  184.    player = GetSourceRef();
  185.  
  186.    // Check that the player is still alive.
  187.    if(GetThingHealth(player) <= 0)
  188.    {
  189.       Return;
  190.    }
  191.  
  192.    if (fireSize > GetInv(player, 90))
  193.       fireSize = GetInv(player, 90);
  194.  
  195.    ChangeInv(player, 90, -1*fireSize);
  196.  
  197.  // Check Ammo - If we are out, autoselect best weapon.
  198.    if(GetInv(player, 90) < 1.0)
  199.    {
  200.       PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
  201.       if(GetAutoSwitch() & 1)
  202.         {
  203.                 // If out of ammo, switch to saber or fists.
  204.             if (GetWeaponPriority(player, GetWeaponBin(11), 0) > 0.0)
  205.                 SelectWeapon(player, GetWeaponBin(11));
  206.             else if (GetWeaponPriority(player, GetWeaponBin(1), 0) > 0.0)
  207.                 SelectWeapon(player, GetWeaponBin(1));
  208.         }
  209.       Return;
  210.    }
  211.  
  212.    SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
  213.  
  214.    while (fireSize > 0)
  215.    {
  216.       // Get random aiming error
  217.       randVec = VectorSet((Rand()-0.5)*2, (Rand()-0.5)*2, 0.0);
  218.       dummy = FireProjectile(player, cprojectile, fireSound, 8, '0.0135 0.1624 0.0', randVec, 4.0, 0x01, autoAimFOV, autoAimFOV*2);
  219.  
  220.       SetThingCollideSize(dummy, 0.2);
  221.  
  222.       fireSize = fireSize - 0.2;
  223.    }
  224.  
  225.    hitSide = 1 - hitSide;
  226.  
  227.    frozen = FirstThingInView(player, 45, freezeradius, 0x404);
  228.  
  229. //    frozen = player;
  230.  
  231.       // Check for things that are being exposed.
  232.    while (frozen != -1)
  233.    {
  234.          // Don't mess with inanimate objects.
  235.       if (!(GetActorFlags(frozen) & 0x100) && (frozen != player))
  236.         {
  237.             if (!(GetThingFlags(frozen) & 0x04))    // Don't freeze Magsealed actors (they're probably already frozen)
  238.             {
  239.                 // Check for Carbonite immunity.
  240.                 if (!(GetPhysicsFlags(frozen) & 0x2000000))
  241.                 {
  242.                     if (VectorDist(GetThingPos(frozen), GetThingPos(player)) < freezeradius)
  243.                     // Double check LOS.
  244.                     if (HasLOS(frozen, player))
  245.                     {
  246.                         for (i = 0; i < 10; i = i + 1)
  247.                         {
  248.                             if (hitList[i] == frozen)
  249.                             {
  250.                                 hitCount[i] = hitCount[i] + 1;
  251.                                 lastHit[i] = hitSide;
  252.     
  253.                                 if (hitCount[i] == 5)
  254.                                 {
  255.                                         // Is this a player?
  256.                                     if (GetThingType(frozen) == 10)
  257.                                     {
  258.     //                                    print("Frozen Player!");
  259.     
  260.                                         SkillTarget(frozen, player, 1035, 6.0);
  261.                                     }
  262.                                     else
  263.                                     {
  264.     //                                    print("Frozen Actor!");
  265.     
  266.                                             // Give the thing a chance to react.
  267.                                         if (SendMessageEx(GetThingClassCog(frozen), skill, 1035, 10.0, frozen, 0) != 17)
  268.                                         {
  269.                                             victim = frozen;
  270.                                         
  271.                                             AISetMode(victim, 0x2000);                // Disable the actor's AI.
  272.                                             AISetMoveThing(victim, victim);           // Set the thing as it's own
  273.                                                                                                     // destination so it stops moving.
  274.                                         
  275.                                                 // Make victim invisible
  276.                                             SetThingFlags(victim, 0x14);
  277.                                             SetActorFlags(victim, 0x8000000);
  278.                                             aiCarbonited = CreateThing(carboDummy, victim);
  279.                                             AttachThingToThing(aiCarbonited, victim);
  280.                                             SetThingCollideSize(aiCarbonited, 0.01);
  281.                                             SetThingFlags(aiCarbonited, 0x04);
  282.                                         
  283.                                             CaptureThing(victim);
  284.                                         
  285.                                                 // Note down what thing the carbonite statue is attached to.
  286.                                             SetThingUserData(aiCarbonited, victim);
  287.                                         
  288.                                             j = -1;
  289.                                         
  290.                                                 // And note down the statue number.
  291.                                             for (k = 0; k < 20; k = k + 1)
  292.                                             {
  293.                                                 if (statueList[k] == -1)
  294.                                                 {
  295.                                                     statueList[k] = aiCarbonited;
  296.                                                     j = k;
  297.                                                     k = 21;
  298.                                                 }
  299.                                             }
  300.                                         
  301.                                                 // No slot found!
  302.                                             if (j == -1)
  303.                                                 DestroyThing(aiCarbonited);
  304.                                         
  305.                                             SendMessageEx(GetInvCog(player, 68), user0, victim, 0, 0, 0);
  306.                                             SetTimerEx(10.0, 101, victim, j);   // Make an appointment for "Unthawing"
  307.     
  308.                                                 // Before going into the default handler (in WEAP_CARBGUN_M.COG)
  309.     //                                        SendMessageEx(GetInvCog(GetLocalPlayerThing(), 140), user0, 1, 10.0, frozen, 0);
  310.                                         }
  311.                                     }
  312.     
  313.                                     hitCount[i] = 0;
  314.                                 }
  315.     
  316.                                 i = 20;
  317.                             }
  318.                         }
  319.     
  320.                         if (i < 20)
  321.                         {
  322.                             for (i = 0; i < 10; i = i + 1)
  323.                             {
  324.                                 if (hitList[i] == -1)
  325.                                 {
  326.                                     hitList[i] = frozen;
  327.                                     hitCount[i] = 1;
  328.                                     lastHit[i] = hitSide;
  329.                                 }
  330.                             }
  331.                         }
  332.                     }
  333.                 }
  334.          }
  335.       }
  336.  
  337.       frozen = NextThingInView();
  338.    }
  339.  
  340.       // Cull any things that are no longer in the cone.
  341.    for (i = 0; i < 10; i = i + 1)
  342.    {
  343.       if (hitList[i] != -1)
  344.          if (lastHit[i] != hitSide)
  345.             hitList[i] = -1;
  346.    }
  347.  
  348.  
  349.    jkPlayPOVKey(player, povfireAnim, 1, 0x38);
  350.  
  351. //   powerBoost = GetInv(player, 63);
  352. //   ChangeFireRate(player, fireWait/powerBoost);
  353.  
  354.    Return;
  355.  
  356. # ........................................................................................
  357.  
  358. mire:        // Butt punch (Hopefully neither Steve A. nor Chris K. will ever see this comment)
  359.    player = GetSourceRef();
  360.  
  361.    // Check that the player is still alive.
  362.    if(GetThingHealth(player) <= 0)
  363.    {
  364.       Return;
  365.    }
  366.  
  367.    SetPOVShake('0.0 -.003 0.0', '1.0 0.0 0.0', .05, 80.0);
  368.    FireProjectile(player, projPunch, fistSound, 44, '0.02 0.03 0', '0 0 0', 1.0, 0, 0.0, 0.0);
  369.  
  370.    jkPlayPOVKey(player, povWhack, 1, 0x38);
  371.  
  372.    Return;
  373.  
  374. # ........................................................................................
  375.  
  376. activated:
  377.    player = GetSourceRef();
  378.    mode = GetSenderRef();
  379.  
  380.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  381.    powerBoost = GetInv(player, 63);
  382.  
  383.    if (mode != 0)
  384.    {
  385.         ActivateWeapon( player, 1.5, mode );
  386.    }
  387.    else
  388.    {
  389.       if (GetInv(player, 93) > 0.0)
  390.       {
  391.          PlaySoundThing(outSound, player, 1.0, -1.0, -1.0, 0x80);
  392.          SendMessageEx(GetThingClassCog(player), skill, 1100, 0, 0, 0);
  393.       }
  394.       else
  395.       {
  396.             // Reset the list of things that are getting carbonite on them.
  397.          hitSide = 0;
  398.  
  399.          for (i = 0; i < 10; i = i + 1)
  400.             hitList[i] = -1;
  401.  
  402.          ActivateWeapon( player, 0.2, mode );
  403.       }
  404.    }
  405.  
  406.    Return;
  407.  
  408. # ........................................................................................
  409.  
  410. deactivated:
  411.    player = GetSourceRef();
  412.  
  413.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  414.    DeactivateWeapon( player, GetSenderRef() );
  415.  
  416.    Return;
  417.  
  418. # ........................................................................................
  419.  
  420. selected:
  421.    player = GetSourceRef();
  422.  
  423.    // Setup the meshes and models.
  424.    if (GetInv(player, 67) == 0.0)
  425.       jkSetPOVModel(player, povModel);    // Kyle hand
  426.    else
  427.       jkSetPOVModel(player, povModel_m);  // Mara Hand
  428.    jkSetWeaponMesh(player, weaponMesh);
  429.    SetArmedMode(player, 1);
  430.  
  431.    // Play mounting sound.
  432.    PlayMode(player, 41);
  433.    PlaySoundThing(mountSound, player, 1.0, -1.0, -1.0, 0x80);
  434.  
  435.    // Play the animation (NOLOOP + UNIQUE + ENDPAUSE).
  436.    // The animation is held at the last frame after it is played.
  437.    trackID = jkPlayPOVKey(player, mountAnim, 0, 0x14);
  438.    jkSetWaggle(player, '10.0 7.0 0.0', 350);
  439.  
  440.    // Clear saber flags, and allow activation of the weapon
  441.    jkClearFlags(player, 0x5);
  442.    SetCurWeapon(player, GetWeaponBin(20));
  443.    SetMountWait(player, GetKeyLen(mountAnim));
  444.  
  445.    Return;
  446.  
  447. # ........................................................................................
  448.  
  449. deselected:
  450.    player = GetSourceRef();
  451.    weaponIndex = GetSenderRef();
  452.  
  453.    PlaySoundThing(dismountSound, player, 1.0, -1, -1, 0x80);
  454.    jkPlayPOVKey(player, dismountAnim, 0, 18);
  455.  
  456.    holsterWait = GetKeyLen(holsterAnim);
  457.    SetMountWait(player, holsterWait);
  458.    holsterTrack = PlayKey(player, holsterAnim, 1, 0x4);
  459.    SetTimerEx(holsterWait, 2, 0.0, 0.0);
  460.    if (trackID != -1)
  461.    {
  462.       jkStopPOVKey(player, trackID, 0);
  463.       trackID = -1;
  464.    }
  465.    jkSetWaggle(player, '0.0 0.0 0.0', 0);
  466.  
  467.    Return;
  468.  
  469. # ........................................................................................
  470.  
  471. autoselect:
  472.    player = GetSourceRef();
  473.  
  474.    // If the player has the weapon
  475.    if(GetInv(player, GetWeaponBin(20)) != 0.0)
  476.    {
  477.       // If the player has ammo
  478.       if(GetInv(player, 90) != 0.0)
  479.       {
  480.          ReturnEx(150.0);
  481.       }
  482.       else
  483.       {
  484.          ReturnEx(-1.0);
  485.       }
  486.    }
  487.    else
  488.    {
  489.       ReturnEx(-1.0);
  490.    }
  491.  
  492.    Return;
  493.  
  494. # ........................................................................................
  495.  
  496. damaged:
  497.    damageType = GetParam (1);
  498.    damage = GetParam(0);
  499.    victim = GetSenderRef();
  500.  
  501.       // If this is impact, explosion or saber damage, kill the player.
  502.    if (BitTest(damageType, 0x15))
  503.    {
  504.       // CreateThing(carboExplode, victim);
  505.  
  506.       debris = CreateThingAtPos(c0Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  507.       SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
  508.       debris = CreateThingAtPos(c1Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  509.       SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
  510.       debris = CreateThingAtPos(c2Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  511.       SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
  512.       debris = CreateThingAtPos(c3Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  513.       SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
  514.       debris = CreateThingAtPos(c4Tpl, GetThingSector(victim), GetThingPos(victim), '0 0 0');
  515.       SetThingVel(debris, VectorSet(rand()-0.5, rand()-0.5, 1.2));
  516.  
  517.       for (i = 0; i < 20; i = i + 1)
  518.       {
  519.          if (statueList[i] != -1)
  520.          if (GetThingUserData(statueList[i]) == victim)
  521.          {
  522.             DestroyThing(statueList[i]);
  523.             statueList[i] = -1;
  524.  
  525.             DestroyThing(victim);
  526.  
  527.                 i = 30;
  528.          }
  529.       }
  530.  
  531.       ReturnEx(GetThingHealth(victim) * 10);
  532.    }
  533.    else
  534.    {
  535.          // Otherwise, no damage.
  536.       ReturnEx(0);
  537.    }
  538.  
  539.    return;
  540.  
  541. # ........................................................................................
  542.  
  543. timer:
  544.    if (GetSenderId() == 2)
  545.    {
  546.       StopKey(player, holsterTrack, 0.0);
  547.    }
  548.    else
  549.    if (GetSenderId() == 3)
  550.    {
  551.       StopKey(player, smackTrack, 0.0);
  552.    }
  553.    else
  554.    if (GetSenderId() == 101)
  555.    {
  556.       victim = GetParam(0);
  557.       j = GetParam(1);
  558.  
  559.          // Make actor visible
  560.       ClearThingFlags(victim, 0x14);
  561.         ClearActorFlags(victim, 0x8000000);
  562.  
  563.          // Enable actor's AI
  564.       AIClearMode(victim, 0x2000);
  565.         AISetMoveThing(victim, player);           // Set the thing moving again
  566.  
  567.       ReleaseThing(victim);
  568.  
  569.         if (j != -1)
  570.         {
  571.                 // Destroy actor's carbonite dummy
  572.             DestroyThing(statueList[j]);
  573.             statueList[j] = -1;
  574.         }
  575.    }
  576.    Return;
  577.  
  578. # ........................................................................................
  579.  
  580. user0:
  581.    victim = GetParam(2);
  582.  
  583.    AISetMode(victim, 0x2000);                // Disable the actor's AI.
  584.    AISetMoveThing(victim, victim);           // Set the thing as it's own
  585.                                              // destination so it stops moving.
  586.  
  587.       // Make victim invisible
  588.    SetThingFlags(victim, 0x14);
  589.     SetActorFlags(victim, 0x8000000);
  590.    aiCarbonited = CreateThing(carboDummy, victim);
  591.    AttachThingToThing(aiCarbonited, victim);
  592.    SetThingCollideSize(aiCarbonited, 0.01);
  593.    SetThingFlags(aiCarbonited, 0x04);
  594.  
  595.    CaptureThing(victim);
  596.  
  597.       // Note down what thing the carbonite statue is attached to.
  598.    SetThingUserData(aiCarbonited, victim);
  599.  
  600.    j = -1;
  601.  
  602.       // And note down the statue number.
  603.    for (k = 0; k < 20; k = k + 1)
  604.    {
  605.       if (statueList[k] == -1)
  606.       {
  607.          statueList[k] = aiCarbonited;
  608.          j = k;
  609.          k = 21;
  610.       }
  611.    }
  612.  
  613.       // No slot found!
  614.    if (j == -1)
  615.       DestroyThing(aiCarbonited);
  616.  
  617.    SendMessageEx(GetInvCog(player, 68), user0, victim, 0, 0, 0);
  618.    SetTimerEx(GetParam(1), 101, victim, j);   // Make an appointment for "Unthawing"
  619.  
  620.    return;
  621.  
  622. end
  623.